package com.nexus.service.sys.service.mapstruct;

import com.nexus.core.service.mapstruct.BaseConverter;
import com.nexus.core.sys.entity.SysUser;
import com.nexus.core.sys.dto.SysUserDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * SysUserWrapper
 *
 * @author 路正宁
 * @version 2023-03-16
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = {})
public interface SysUserWrapper extends BaseConverter<SysUser,SysUserDTO> {

    SysUserWrapper INSTANCE = Mappers.getMapper(SysUserWrapper.class);

    @Mappings({
            @Mapping(source = "office.id", target = "office"),
            @Mapping(source = "post.id", target = "post"),
            @Mapping(source = "createBy.id", target = "createBy"),
            @Mapping(source = "updateBy.id", target = "updateBy")})
    SysUser toEntity(SysUserDTO dto);

    @Mappings({
            @Mapping(source = "office", target = "office.id"),
            @Mapping(source = "post", target = "post.id"),
            @Mapping(source = "createBy", target = "createBy.id"),
            @Mapping(source = "updateBy", target = "updateBy.id")})
    SysUserDTO toDTO(SysUser entity);
}

